﻿Public Partial Class ViewRoleMembers
    Inherits BaseUserControl

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            Rebind()
        End If
    End Sub

    Private Sub Page_OnUpdate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.OnUpdate
        Rebind()
    End Sub

    Public Overrides Sub Rebind()
        Try
            drpRoles.Items.Clear()
            drpRoles.DataSource = Roles.GetAllRoles
            drpRoles.DataBind()
        Catch ex As Exception
            Me.RaiseError(ex)
        End Try
    End Sub

    Protected Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Try
            Dim users() As String = Roles.GetUsersInRole(drpRoles.SelectedItem.Text)
            If users.Length > 0 Then
                rptUsers.DataSource = users
                rptUsers.DataBind()
                rptUsers.Visible = True
            Else
                Me.Prompt("No user found!", UserControlPromptTypes.Alert)
                rptUsers.Visible = False
            End If
        Catch ex As Exception
            Me.RaiseError(ex)
        End Try
    End Sub

End Class